package com.example.transation.controller;

import com.example.transation.service.LogService;
import com.example.transation.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RequestMapping("/user")
@RestController
public class UserController2 {
    @Autowired
    private UserService userService;
    @Autowired
    private LogService logService;

    @Transactional(propagation = Propagation.REQUIRED)
    @RequestMapping("/p1")
    public String r3(String name, String password) {
        //⽤⼾注册
        userService.registUser(name, password);
        //记录操作⽇志
        logService.insertLog(name, "⽤⼾注册");
        return "p1";
    }
}
